
#include "common.h"
#include "event.h"
#include "packet.h"


class RecvPackEvent : public Event{
	public:
		RecvPackEvent( EventHandler *h, Packet *p )
			: Event( RECV_PACK, h )
			, packet_( p )
		{
			packet_->add_reference();
		}

		~RecvPackEvent() { RELEASE_OBJ(packet_) }

		Packet* getPacket() {return packet_;}

	protected:
		Packet *packet_;
};

class NodeJoinEvent : public Event{
	public:
		NodeJoinEvent( EventHandler *h, node_id_t n_id )
			: Event( NODE_JOIN, h )
			, node_id_(n_id)
		{}
		node_id_t nodeID() const { return node_id_; }

	protected:
		node_id_t node_id_;
};

class NodeDepartureEvent : public Event{
	public:
		NodeDepartureEvent( EventHandler *h, node_id_t n_id )
			: Event( NODE_DEPARTURE, h )
			, node_id_(n_id)
		{}
		node_id_t nodeID() const { return node_id_; }

	protected:
		node_id_t node_id_;
};

class CmdEvent : public Event{
	public:
		enum COMMAND_TYPE{
			CMD_ILLEGAL
		};
		CmdEvent( EventHandler *h, COMMAND_TYPE c )
			: Event( COMMAND, h )
			, cmd_( c )
		{}
		COMMAND_TYPE cmd() const { return cmd_; }
	protected:
		COMMAND_TYPE cmd_;
};
